package com.foucus.myfouces.Resource.Util;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;


import java.io.File;

public class Const {

//    public static final String COMMON_ADDRESS = "http://192.168.31.128:8083//api/";//线下接口

    public static final String COMMON_ADDRESS = "http://121.43.232.79/api/";  //线上接口

    public static final String CHAT_ADDRESS = "http://120.25.241.183/interface.php?m=member&a=setMess";

    public static final String AVATAR_ADDRESS = "http://120.25.241.183/interface.php?m=public&a=upload";

    public static final String POST_ADDRESS = "http://120.25.241.183/interface.php?m=member&a=setPosts";

    public static final String ENCODE = "utf-8";

    public static final String APPID = "id";

    public static final String APPSECRET = "secret";

    public static final String APPVERSION = "1.0";

    public static String RSA_PUBLICKEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApjLPr+9dzmvB5NoKVGmQCTxie081LVD5wftxz1pDBxZdmOGNs6E3h9hsC4Rci2CcexUBdHNK6ZhacewFQELGjFQLaxyo40FbGIkzXJBgy5meeTr0NnLFFh4XxBd6F472xoQlT5yBGryGEodZVdRaovxRsl8xSAqWAwzcpkOcjCkyxmu0Id2yNXpIFCW59VSzPTxBsYbErU1ke7lRHrr0KGGIajO7ywwm3TSrruZk35l5rgwLCBKobAv9hEiKH2Cr2cQ1kruFCDOb2sSqOvExKde1nIYZfC19KKeObDdUchZO3Qek5ViiJiYvDVqp2iFOLD65jVnOuPrAc3dyQIDAQAB";


//    //图片加载图
//    public static DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
//            .showImageOnLoading(R.mipmap.ic_launcher)//设置图片在下载期间显示的图片
//            .showImageForEmptyUri(R.mipmap.ic_launcher)//设置图片Uri为空或是错误的时候显示的
//            .showImageOnFail(R.mipmap.ic_launcher)//设置图片加载/解码过程中错误时候显示的图片
//            .cacheInMemory()//设置下载的图片是否缓存在内存中
//            .cacheOnDisk(true)//设置下载的图片是否缓存在SD卡中
//            .considerExifParams(true) //是否考虑JPEG图像EXIF参数（旋转，翻转）
//            .imageScaleType((ImageScaleType.IN_SAMPLE_INT))//设置图片以如何的编码方式显示
//            //.decodingOptions(BitmapFactory.Options decodingOptions)//设置图片的解码配置
////            .displayer(new RoundedBitmapDisplayer(20))//不推荐用！！！！是否设置为圆角，弧度为多少
////            .displayer(new FadeInBitmapDisplayer(100))//是否图片加载好后渐入的动画时间，可能会出现闪动
//            .bitmapConfig(Bitmap.Config.RGB_565)//设置图片的解码类型
//            .build();
//
//    public static DisplayImageOptions options = new DisplayImageOptions.Builder()
//            .showImageOnLoading(R.mipmap.ic_launcher)
//            .showImageForEmptyUri(R.mipmap.ic_launcher)
//            .showImageOnFail(R.mipmap.ic_launcher)
//            .cacheInMemory(true)
//            .cacheOnDisk(true)
//            .considerExifParams(true)
//            .displayer(new FadeInBitmapDisplayer(300))
//            .build();
//
//    //头像
//    public static DisplayImageOptions displayImageOptions_head = new DisplayImageOptions.Builder().showImageOnLoading(R.mipmap.icon_head_default)
//            .showImageForEmptyUri(R.mipmap.icon_head_default).showImageOnFail(R.mipmap.icon_head_default).cacheInMemory(true).cacheOnDisk(true)
//            .considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565).build();
//
//    //搜索
//    public static DisplayImageOptions search_displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.mipmap.icon_search)
//            .showImageForEmptyUri(R.mipmap.icon_search).showImageOnFail(R.mipmap.icon_search).cacheInMemory(true).cacheOnDisk(true)
//            .considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565).build();
//
//
//    public static DisplayImageOptions getDisplayOptions(
//            BitmapFactory.Options decodingOptions) {
//        DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder()
//                .bitmapConfig(Bitmap.Config.RGB_565)
//                .resetViewBeforeLoading(true).cacheOnDisk(false);
//        if (decodingOptions != null) {
//            builder = builder.decodingOptions(decodingOptions);
//        }
//        return builder.build();
//    }

    public static BitmapFactory.Options getDecodingOptions(String dir,
                                                           String fileName, int reqWidth, int reqHeight) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(dir + File.separator + fileName, options);
        options.inSampleSize = calculateInSampleSize(options, reqWidth,
                reqHeight);
        options.inJustDecodeBounds = false;
        return options;
    }

    public static int calculateInSampleSize(
            BitmapFactory.Options options, int reqWidth, int reqHeight) {
        // Raw height and width of image
        final int height = options.outHeight;
        final int width = options.outWidth;
        int inSampleSize = 1;

        if (height > reqHeight || width > reqWidth) {

            final int halfHeight = height / 2;
            final int halfWidth = width / 2;

            // Calculate the largest inSampleSize value that is a power of 2 and keeps both
            // height and width larger than the requested height and width.
            while ((halfHeight / inSampleSize) > reqHeight
                    && (halfWidth / inSampleSize) > reqWidth) {
                inSampleSize *= 2;
            }
        }
        return inSampleSize;
    }


    //mob官网（http://www.mob.com/）
    public static final String Appkey = "10eba444839b6";
    public static final String AppSecret = "294da7dba21645d6a936d2fde0ffb255";

    //微信
    public static final String WX_Appkey = "wx4fd506fcc4714254";
    public static final String WX_AppSecret = "7e2f25a37c07ba7ed6f358ca25d6b2a6";

    //qq
    public static final String QQ_Appkey = "101317234";

    //新浪微博
    public static final String SINA_Appkey = "1114579256";
    public static final String SINA_AppSecret = "dc7098da90359d33ee6970ea3642f426";
}
